/*
 * Copyright 2010-2011 Marcin Blazejewski
 *
 * This file is part of Ground0.
 *
 * Ground0 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Ground0 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Ground0. If not, see <http://www.gnu.org/licenses/>.
 *
 */


#ifndef EYE_H_
#define EYE_H_

#include "stuff.hpp"

#include <list>
#include <map>
#include <string>
#include <GL/gl.h>

using namespace std;

class Scene {
protected:
public:
    virtual void              render() = 0;
    virtual void              tick(unsigned int ms) = 0;
    virtual class Camera*     get_camera() = 0;
    virtual void              set_camera(class Camera*) = 0;
};

class BasicScene : public Scene {
protected:
    class Camera *camera;
    Light         ambient;
    Light         lights[8];

    void          relight();
    void          render_light();

public:
    BasicScene();
    Camera*       get_camera() { return camera; }
    void          set_camera(class Camera *cam);
};

class Eye {
private:
    static Eye   *instance;
    int           width, height, bpp;
    Material      *mat_font;
    GLuint        fontbase;

protected:
    struct SDL_Surface *screen;
    bool          fs;
    bool          fog;
    bool          wireframe;
    GLfloat       fogColor[4];
    float         clip_dist;

public:
    Eye(int w, int h, int bpp, bool fs, const char *title="");
    ~Eye();
    
    void          resize(int w, int h);
    void          toggle_fullscreen();

    void          load_font(const char *fname);
    void          print(int x, int y, const char *s);

    void          set_fov(float fov);

    GLuint         marker_dl;
};

class Controller {
public:
    virtual void  on_keydown(struct SDL_KeyboardEvent *ev) = 0;
    virtual void  on_keyup(struct SDL_KeyboardEvent *ev) = 0;
    virtual void  on_mouse_down(struct SDL_MouseButtonEvent *ev) {}
    virtual void  on_mouse_up(struct SDL_MouseButtonEvent *ev) {}
};

#endif
